package com.gxa.service.shezhiservice.Impl;

import com.gxa.common.R;
import com.gxa.mapper.shezhimapper.JieSuanWay46Mapper;
import com.gxa.pojo.GongYingShangType;
import com.gxa.pojo.JieSuanWay;
import com.gxa.service.shezhiservice.JieSuanWay46Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JieSuanWay46ServiceImpl implements JieSuanWay46Service {

    @Autowired
    private JieSuanWay46Mapper jieSuanWay46Mapper;
    @Override
    public R selectAllJieSuanWayForPage(int page, int size) {

        R r = new R();
        int index = (page - 1)*size;
        List<JieSuanWay> jieSuanWays  = jieSuanWay46Mapper.selectAllJieSuanWayForPage(index,size);
        if (jieSuanWays != null){
            r.setCode(200);
            r.setMsg("查询成功！");
            r.setData(jieSuanWays);
        }
        return r;
    }


    @Override
    public R insertJieSuanWay(JieSuanWay way) {
        R r = new R();
        int res =  jieSuanWay46Mapper.insertJieSuanWay(way);
        r.setCode(500);
        r.setMsg("新增失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("新增成功");
        }
        return r;
    }

    @Override
    public R updateJieSuanWayById(JieSuanWay way) {
        R r = new R();
        int res =  jieSuanWay46Mapper.updateJieSuanWayById(way);
        r.setCode(500);
        r.setMsg("更新失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("更新成功");
        }
        return r;
    }

    @Override
    public R deleteJieSuanWayById(int id) {
        R r = new R();
        int res = jieSuanWay46Mapper.deleteJieSuanWayById(id);
        r.setCode(500);
        r.setMsg("删除失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("删除成功");
        }
        return r;
    }

}

